package com.retallife.user.service.Chat.Impl;

import com.retallife.user.dao.Chat.ChatMapper;
import com.retallife.user.pojo.Chat.ChatDeleteFriendVo;
import com.retallife.user.pojo.Chat.ChatFriendsVo;
import com.retallife.user.pojo.Chat.ChatMsgVo;
import com.retallife.user.pojo.Chat.ChatMsgToFromVo;
import com.retallife.user.service.Chat.ChatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChatServiceImpl implements ChatService {

    @Autowired
    ChatMapper chatMapper;

    /**
     * 查询聊天记录
     * @param chatMsgToFromVo
     * @return 查询记录
     */
    public List<ChatMsgVo> LookTwoUserMsg(ChatMsgToFromVo chatMsgToFromVo) {
        return chatMapper.LookTwoUserMsg(chatMsgToFromVo);
    }

    /**
     * 查询用户的好友
     * @param userName
     * @return 查询记录
     */
    public List<ChatFriendsVo> LookUserAllFriends(String userName) {
        return chatMapper.LookUserAllFriends(userName);
    }

    /**
     * 添加聊天信息
     * @param chatMsgVo
     * @return 是否添加成功
     */
    public int InsertChatMsg(ChatMsgVo chatMsgVo) {
        return chatMapper.InsertChatMsg(chatMsgVo);
    }

    /**
     * 添加好友
     * @param chatFriends
     */
    public int InsertUserFriend(ChatFriendsVo chatFriends) {
        return chatMapper.InsertUserFriend(chatFriends);
    }

    /**
     * 删除chatfriends表中的好友记录
     * @param chatDeleteFriendVo
     * @return 是否删除成功
     */
    public int DeleteChatFriend(ChatDeleteFriendVo chatDeleteFriendVo) {
        return chatMapper.DeleteChatFriend(chatDeleteFriendVo);
    }

    /**
     * 删除chatmsg表中的两个人的聊天记录
     * @return 是否删除成功
     */
    public int DeleteMsgFriend(ChatDeleteFriendVo chatDeleteFriendVo) {
        return chatMapper.DeleteMsgFriend(chatDeleteFriendVo);
    }
}
